#include <iostream>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<deque>
#include<set>
using namespace std;

class Solution {
public:
    vector<int> maxSlidingWindow(vector<int>& nums, int k) {
        vector<int> result;
        multiset <int> mSet;

        for (size_t i = 0; i < k; i++)
        {
            mSet.insert(nums[i]);
        }
        result.push_back(*mSet.rbegin());
        
        for (size_t i = 0; i < nums.size()-k; i++)
        {
            mSet.insert(nums[k+i]);
            mSet.erase(mSet.find(nums[i]));
            result.push_back(*mSet.rbegin());
        }
        return result;

    }
};

int main2()
{
    Solution so;
    vector<int> nums{-7,-8,7,5,7,1,6,0};
    so.maxSlidingWindow(nums,3);
    return 0;
}